//@json
function main(tbl) {
	print(Jse.webapp)
//	//1、从服务器获取摄像头识别记录
//	let HttpHelper = Java.type('api.HttpHelper')
//	let httpHelper = new HttpHelper()
//	let consumerId = httpHelper.getConsumerId()
//	let consumer = httpHelper.post('https://api2.hik-cloud.com/api/v1/mq/consumer/messages?autoCommit=false&consumerId=' + consumerId,'application/x-www-form-urlencoded;charset=UTF-8',null)
//	let data = consumer.data
//	//print(data)
//	for(let i = 0 ; i < data.length ; i++){
//		if(data[i].msgType == "open_device_onoffline"){
//			//设备上下线消息
//			let content = Json.fromJson(data[i].content)
//			let trail_device = dao.fetch("trail_device", Cnd.where("device_id", "=", content.deviceId))
//			if(trail_device!=null){
//				if(content.msgType == "ONLINE"){
//					trail_device.status = 1
//				}else{
//					trail_device.status = 2
//				}
//				trail_device.table = "trail_device"
//				try {
//					$mager(trail_device)
//					print("===>>> 设备在线状态更新成功")
//				} catch (e) {
//					print("===>>> 设备在线状态更新失败")
//				}
//			}
//		}
//		if(data[i].msgType == "open_event_super_brain_faces_comparison"){
//			//人脸对比消息
//			let content = Json.fromJson(data[i].content)
//			for(let j = 0 ; j < content.length ; j++){
//				//根据设备序列号查询设备
//				let device = dao.fetch("trail_device", Cnd.where("device_code", "=", content[j].deviceSerial))
//				//获取识别到的用户信息
//				for(let k = 0 ; k < content[j].faces.length ; k++){
//					for(let l = 0 ; l < content[j].faces[k].identify.length ; l++){
//						let candidate = content[j].faces[k].identify[l].candidate
//						for(let m = 0 ; m < candidate.length ; m++){
//							let trail_user = dao.fetch("trail_user", Cnd.where("userface_id", "=", candidate[m].employeeNo))
//							var new_trail_device_log = {}
//							new_trail_device_log.table="trail_device_log"
//							new_trail_device_log.device_id=device.device_id
//							new_trail_device_log.trail_id=device.trail_id
//							new_trail_device_log.site=device.site
//							new_trail_device_log.user_id=trail_user.id
//							new_trail_device_log.code=device.code
//							new_trail_device_log.trail_username=trail_user.username
//							new_trail_device_log.trail_userface=trail_user.userface
//
//							//摄像头识别的时间
//							let facetime = new Date(content[j].targetAttrs.faceTime)
//							facetime = new Date(facetime)
//							
//							//30秒前
//							let facetime_s30 = new Date(facetime.getTime() - 120000)
//							facetime_s30 = facetime_s30.toLocaleDateString() + " " + facetime_s30.toLocaleTimeString()
//							
//							//20分钟前
//							let facetime_min20 = new Date(facetime.getTime() - 1200000)
//							facetime_min20 = facetime_min20.toLocaleDateString() + " " + facetime_min20.toLocaleTimeString()
//							
//							//摄像头识别的时间（当前时间)
//							facetime = facetime.toLocaleDateString() + " " + facetime.toLocaleTimeString()
//							
//							print(facetime +"<>"+ facetime_s30 )
//							
//							//1、判断用户30秒内是否经过此摄像头，若30秒经过同一摄像头，数据包丢掉，不做处理
//							let trail_device_log = dao.fetch("trail_device_log", Cnd.where("user_id","=",trail_user.id).and("device_id", "=", device.device_id).and("update_time",">=",facetime_s30).and("update_time","<=",facetime).desc("update_time"))
//							if(null == trail_device_log){
//								//非识别，重复识别 
//								//2、判断用户20分钟内是否有同一步道的其他摄像头是被记录，若没有，视为开始运动
//								let trail_device_log = dao.fetch("trail_device_log", Cnd.where("user_id","=",trail_user.id).and("update_time",">=",facetime_min20).and("update_time","<=",facetime).desc("update_time"))
//								if(trail_device_log == null || trail_device_log.device_id == device.device_id){
//									//开始运动
//									new_trail_device_log.type=0
//									new_trail_device_log.add_time=facetime
//									new_trail_device_log.update_time=facetime
//									$save(new_trail_device_log)
//									print("=============>>> 开始新运动")
//								}else{
//									//3、若2条件成立，视为运动过程，记录摄像头识别记录，并更新当天运动结果
//									new_trail_device_log.type=1
//									new_trail_device_log.add_time=facetime
//									new_trail_device_log.update_time=facetime
//									$save(new_trail_device_log)
//									//计算运动结果
//									//获取两个摄像头之间的距离
//									let trail_config = dao.fetch("trail_config", Cnd.where("trail_device_idA","=",trail_device_log.id).and("trail_device_idB","=",new_trail_device_log.id))
//									if(null == trail_config){
//										trail_config = dao.fetch("trail_config", Cnd.where("trail_device_idB","=",trail_device_log.id).and("trail_device_idA","=",new_trail_device_log.id))
//									}
//									if(null != trail_config){
//										//开始计算
//										let weight = 40;
//										if(trail_user.weight == "40-50kg")
//											weight = 45;
//										else if(trail_user.weight == "50-60kg")
//											weight = 55;
//										else if(trail_user.weight == "60-70kg")
//											weight = 65;
//										else if(trail_user.weight == "70-80kg")
//											weight = 75;
//										else if(trail_user.weight == "80-90kg")
//											weight = 85;		
//										else 
//											weight = 100;
//										let kcal = trail_config.distance / 1000 * weight *1.036;
//										let today = new Date().toLocaleDateString()
//										let time2 = new Date(new_trail_device_log.update_time)
//										let time1 = new Date(trail_device_log.update_time)
//										
//										
//										//查询有没有历史运动数据
//										let trail_runinfo = dao.fetch("trail_config", Cnd.where("trail_id","=",device.trail_id).and("trail_user_id","=",trail_user.id).and("run_date","=",today))
//										if(null == trail_runinfo){
//											print("=============>>> 今日运动数据初始化")
//											trail_runinfo = {}
//											trail_runinfo.trail_id = device.trail_id
//											trail_runinfo.trail_user_id = trail_user.id
//											trail_runinfo.mileage = trail_config.distance
//											trail_runinfo.run_date = today
//											trail_runinfo.kcal = kcal
//											trail_runinfo.run_time = (time2.getTime() - time1.getTime())/1000
//											trail_runinfo.speed = (trail_runinfo.mileage/trail_runinfo.run_time)*3.6
//											$save(trail_runinfo)
//										}else{
//											print("=============>>> 今日运动数据追加")
//											trail_runinfo.mileage = trail_runinfo.mileage + trail_config.distance
//											trail_runinfo.kcal = trail_runinfo.kcal + kcal
//											trail_runinfo.run_time = trail_runinfo.run_time + ((time2.getTime() - time1.getTime())/1000)
//											trail_runinfo.speed = (trail_runinfo.speed + ((trail_runinfo.mileage/trail_runinfo.run_time)*3.6))/2
//											$mager(trail_runinfo)
//										}
//									}
//								}
//							}else{
//								//更新一下识别记录里的识别时间
//								print("=============>>> 重复运动")
//								trail_device_log.update_time = facetime
//								trail_device_log.table="trail_device_log"
//								$mager(trail_device_log)
//							}
//						}
//					}
//				}
//			}
//		}
//	}	
}